# ----------------------------------------------------------------------------
#       Copyright (C) 2013-2014 Huynh Vi Lam  <domovilam@gmail.com>
#
#       This file is part of pimucha.
#
#	This program is free software: you can redistribute it and/or modify
#	it under the terms of the GNU General Public License as published by
#	the Free Software Foundation, either version 3 of the License, or
#	(at your option) any later version.
#	
#	This program is distributed in the hope that it will be useful,
#	but WITHOUT ANY WARRANTY; without even the implied warranty of
#	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#	GNU General Public License for more details.
#	
#	You should have received a copy of the GNU General Public License
#	along with this program.  If not, see <http://www.gnu.org/licenses/>.
# ----------------------------------------------------------------------------



# ----------------------------------------------------------------------------
# CM1xa additionnal functions
# Python version 2.7.x and 3.x
# ----------------------------------------------------------------------------
# Software MOCHAD
# ---------------
# - Website: http://sourceforge.net/apps/mediawiki/mochad/index.php?title=Main_Page
# - MOCHAD is used as base for development of scripts
#
# Software CM15ademo
# ---------------
# - Website: http://www.eclipsehomeauto.com/
# - CM15ademo is used as base for development of scripts
# ----------------------------------------------------------------------------


import datetime


def clockbuf():
    d = datetime.date.strftime(datetime.datetime.today(),"%S %M %H %j %w").split()
    buf = [155]		#0x9b
    buf.append(int(d[0]))
    buf.append(int(d[1]) + ((int(d[2]) % 2) * 60 ))
    buf.append(int(d[2]) / 2)
    buf.append(int(d[3]))
    buf.append(1 << int(d[4]))
    if(int(d[3]) & 0x100):
	buf[4] &= 0x80
	buf[5] |= 0x80
    buf.append(0x60)
    buf.append(0x00)
    return buf
